<template>
	<view class="content">
		<view class="wid100 " style="height: 416rpx;">
			<image src="../../static/tu9.png" class="wh100"></image>
		</view>
		<view class="wid90 mar bacFFF borRad20 mar-top30" style="box-shadow: 0rpx 5rpx 20rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl disJuB" style="height: 104rpx;">
				<view class="foSi35 fowe600">姓名</view>
				<input class="foSi25 wid70" style="text-align: right;" v-model="name" placeholder="输入您的姓名"/>
			</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 104rpx;">
				<view class="foSi35 fowe600">手机号</view>
				<input class="foSi25 wid70" style="text-align: right;" type="number" v-model="phone" placeholder="输入您的手机号"/>
			</view>
		</view>
		<view class="wid90 mar bacFFF borRad40 dis disAl disJuC hei86 foSi35 fowe600 mar-top40 coFFF"
			:style="'background-color: '+theme.main_color+';'" @click="tijiao()">提交申请</view>
		<view style="height: 57rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				name: '',
				phone: '',
				theme: null
				
			}
		},
		onLoad() {
			this.theme = uni.getStorageSync('theme')
		},
		methods: {
			tijiao(){
				var that = this;
				if(!that.name){return uni.showToast({title: '请输入姓名',icon: 'error',duration: 2000})};
				//正则表达式定义手机号正确格式
				let reg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
				if (!reg.test(this.phone)){return uni.showToast({title: '请输入正确手机号',icon: 'error',duration: 2000})};
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/distr/distr_apply',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						phone: that.phone,
						name: that.name
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							uni.navigateBack(1)
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'none',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
</style>
